/* Bitte ausfüllen
 * Name: Alexander Kaack
 * Matrikelnummer: 22222
 */
package pruefung;

import java.util.*;
import static com.google.common.base.Preconditions.*;

/**
 *
 * @author oelker_g
 */
public class Pruefung {
//
//    /**
//     * @param args the command line arguments
//     */
//    public static void main(String[] args) {
//        // TODO code application logic here
//    }
    
    public static List<List<String>> transposeList(List<List<String>> list) {
        checkArgument(list.size()>0&&list.subList(0, list.size()).size()>0);
        
        List<List<String>> newList = new ArrayList<List<String>>();
        
        for (int i = 0; i < list.get(0).size(); i++) {
            
            List<String> innerList = new ArrayList<String>();
            
            for (int j = 0; j < list.size(); j++) {
                innerList.add(list.get(j).get(i));
                
            }
            newList.add(innerList);
            
        }
   
        return newList;
    }
    
    public static Set<String> symmDiff(Set<String> set1, Set<String> set2) {
        checkArgument(!set1.isEmpty()&&!set2.isEmpty());
        Set<String> set3 = new HashSet<String>();
        Set<String> set4 = new HashSet<String>();
        
        set3.addAll(set1);
        set3.removeAll(set2);
        
        set4.addAll(set2);
        set4.removeAll(set1);
        
        set3.addAll(set4);
               
        return set3;
    }
    
    public static Set<?> deepCopyTree(Set<?> set) {
        checkArgument(set != null);
        
        Set<Object> tree = new HashSet<Object>();
        
        for(Object e : set){
            if(e instanceof Set) {
                tree.add(deepCopyTree((Set)e));
            }else{
                        tree.add(e);
            }
        }        
        
        return tree;
    }
    
    public static Map<String,List<String>> setToMultiMap(Set<List<String>> set1) {
    
    Map<String,List<String>> result = new HashMap<String,List<String>>();
    
        for (List<String> list : set1) {
            if(result.containsKey(list.get(0))) {
                
                result.get(list.get(0)).add(list.get(1));
                
            }else{
                List<String> tmp = new ArrayList<String>();
                tmp.add(list.get(1));
                result.put(list.get(0), tmp);
            }
            
        }
    
    return result;
    
    }
}
